package Test11.topic.cn.tedu;

import java.util.*;

/*本类用于作业键值对--Map*/
/*需求：随机输入一串字符串，统计这串字符串中每个字母的出现次数*/
public class Map1 {
    public static void main(String[] args) {
        System.out.println("请输入一串英文字母:");
        String a = new Scanner(System.in).nextLine();
        a.toLowerCase();
        int[] b = new int[26];
        Map<Character,Integer> map = new HashMap<>();
        for (int i = 0; i <a.length() ; i++) {
            char q;
            int w;
            q = a.charAt(i);
            w = q-'a';
            b[w] = b[w]+1;
            //System.out.println(q);
            map.put(q,w);

        }
        System.out.println(map);
//        Set<Character> set = map.keySet();
//        Iterator<Character> it = set.iterator();
//        while(it.hasNext()){
//            System.out.println(it.next());
//        }
    }
}
